<include file="public@header"/>
<style>
    th {
        font-size: 14px;
    }
</style>
</head>
<body>
<div class="wrap js-check-wrap">
    <ul class="nav nav-tabs">
        <li class="active"><a href="{:url('Stuff/index')}">材料库</a></li>
        <li><a href="{:url('Stuff/add')}">新增材料</a></li>
    </ul>
    <div>
        <form class="well form-search" action="{:url('Stuff/index')}" method="get">
            <label>材料类型:
                <select class="form-control" name="cate_name">
                    <option value="">——请选择——</option>
                    <volist name="cate" id="vo">
                        <option value="{$vo.cate_name}" <if condition="$cate_name eq $vo.cate_name">selected</if>> {$vo.cate_name}</option>
                    </volist>
                </select></label>
            <label>材料名称:
                <input type="text" name="stuff_name" class="form-control" placeholder="请输入材料名称"
                       value="{:input('request.stuff_name')}">
            </label>
            <input type="submit" class="btn btn-primary" value="搜索"/>
            <a class="btn btn-danger" href="{:url('Stuff/index')}">清空</a>
        </form>
    </div>
    <form class="js-ajax-form" action="{:url('Stuff/listOrder')}" method="post">
        <php>$status = array('1' => '下架', '0' => '上架');</php>
        <table class="table table-hover table-bordered">
            <thead>
            <tr>
                <th width="10%">{:lang('SORT')}</th>
                <th width="10%">ID</th>
                <th width="15%">材料名称</th>
                <th width="10%">{:lang('CATE_NAME')}</th>
                <th width="10%">价格</th>
                <th width="10%">{:lang('ROCK_IMG')}</th>
                <th width="15%">添加时间</th>
                <th width="15%">状态</th>
            </tr>
            </thead>
            <tbody>
            <foreach name="results" item="vo">
                <tr>
                    <td><input name="list_orders[{$vo.id}]" type='text' size='3' value='{$vo.list_order}' class='input input-order'></td>
                    <td>{$vo.id}</td>
                    <td>{$vo.stuff_name}</td>
                    <td>{$vo.cate_name}</td>
                    <td>{$vo.stuff_money}/{$vo.stuff_unit}</td>
                    <td>
                        <if condition="!empty($vo['stuff_image'])">
                            <a href="javascript:imagePreviewDialog('{:cmf_get_image_preview_url($vo.stuff_image)}');">
                                <i class="fa fa-photo fa-fw"></i>
                            </a>
                        </if>
                    </td>
                    <td><php>echo date('Y-m-d H:i:s', $vo['add_time'])</php>
                    </td>
                    <td>
                        <a href="" data-id="{$vo.id}" data-href="{:url('Stuff/edit')}" class="editClass" >{:lang('EDIT')}</a>
                        |
                        <a href="{:url('Stuff/delete',array('id'=>$vo['id']))}"
                           class="js-ajax-delete">{:lang('DELETE')}</a>
                    </td>
                </tr>
            </foreach>
            </tbody>
        </table>
        <div class="table-actions">
            <button class="btn btn-primary btn-sm js-ajax-submit" type="submit">{:lang('SORT')}</button>
        </div>
        <div class="pagination">{$page}</div>
    </form>

</div>
<script type="text/javascript" src="__STATIC__/js/admin.js?v={:time()}"></script>
<script type="text/javascript">

    $(".editClass").click(function () {

        var num = $(".pagination").find(".active").find("span").html();
        var id= $(this).data("id");
        var url = $(this).data("href")+"?id="+id+"&page="+num;
        $(this).attr("href",url);

    });

</script>
</body>
</html>